package com.ruoyi.system.controller;

import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.system.domain.Student;

/**
 * 反射Controller
 * 
 * @author ruoyi
 * @date 2024-04-19
 */
@Controller
@RequestMapping("/system/fanshe")
public class FanSheController extends BaseController
{
    private String prefix = "system/fanshe";


    @RequiresPermissions("system:fanshe:view")
    @GetMapping()
    @ResponseBody
    public String student()
    {
        return "There is nothing.";
    }

    /**
     * 通过反射获取String类的所有方法，并打印出来
     */
    @RequiresPermissions("system:fanshe:list")
    @GetMapping("/list")
    @ResponseBody
    public String list(Student student)
    {
    	Set<String> resp = new HashSet<>();
    	// 获取类名
        String className = "java.lang.String";

        try {
            // 使用反射加载类
            Class<?> clazz = Class.forName(className);

            // 获取类的所有方法
            Method[] methods = clazz.getDeclaredMethods();

            // 打印方法名
            System.out.println("Methods of " + className + ":");
            for (Method method : methods) {
            	resp.add(method.getName());
            }
        } catch (ClassNotFoundException e) {
            System.out.println("Class not found: " + className);
        }
        return resp.toString();
    }

    
}
